package copyengine.ui.component.progress
{
    import copyengine.ui.component.CEUIComponent;
    import copyengine.ui.component.progress.animation.ICEProgressBarAnimation;
    import copyengine.utils.GeneralUtils;

    import starling.display.DisplayObject;

    public class CEProgressBar extends CEUIComponent
    {
        private var mCurrentPercent:Number = 100;
        private var mAnimation:ICEProgressBarAnimation;

        public function CEProgressBar(_container:DisplayObject)
        {
            super(_container);
        }

        public function set animation(_animation:ICEProgressBarAnimation):void
        {
            mAnimation = _animation;
            mAnimation.onPercentChange(mCurrentPercent);
        }

        public function get percent():Number {return mCurrentPercent;}

        public function set percent(_value:Number):void
        {
            if (_value != mCurrentPercent) {
                mCurrentPercent = GeneralUtils.normalizingValue(_value, 0, 100);
                mAnimation && mAnimation.onPercentChange(mCurrentPercent);
            }
        }

    }
}
